const CracoAntDesignPlugin = require('craco-antd')
const path = require('path')
const webpackPlugins = []
if (process.env.NODE_ENV === 'production') {
  // 打包分析
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
  // npm run build的时候浏览器会自动打开9090端口的一个页面显示当前依赖包的各种大小拼图
  webpackPlugins.push(new BundleAnalyzerPlugin({ analyzerPort: 9090 }))
}

module.exports = {
  webpack: {
    // 别名
    alias: {
      '@': path.resolve(__dirname, 'src'),
      'react': path.resolve('./node_modules/react'),
    },
    plugins: webpackPlugins,
  },
  plugins: [
    // antd：https://ant.design/docs/react/use-in-typescript-cn
    {
      plugin: CracoAntDesignPlugin,
      options: {
        customizeTheme: {
          '@primary-color': '#1890FF',
        },
      },
    },
  ],
}
